__author__ = 'wangjc'

import yaml
from appium import webdriver

class BaseDriver:


    def base_driver(self, device, automationName="Appium", noReset=True):
        fs = open(r"..\Caps\Caps.yaml", encoding="utf-8")
        datas = yaml.load(fs,Loader=yaml.FullLoader)
        for i in datas:
            if device == i["deviceDesc"]:
                if automationName != "Appium":
                    i["desired_caps"]["automationName"] = automationName
                if noReset == False:
                    i["desired_caps"]["noReset"] = False
                desired_caps = {
                    "platformName": "Android",
                    "app": "E:\\dongfeng-capp-gold1-20201013.apk",
                    "deviceName": "127.0.0.1:62001"
                }
                driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)
                # driver.implicitly_wait(10)
                return driver

    if __name__ == '__main__':
        # base_driver('','Honor_V8', automationName="Appium", noReset=True)
        desired_caps = {'platformName': 'Android',
                        'deviceName': 'TWGDU16926018976',
                        'platformVersion': '23',
                        'appPackage': 'com.aerozhonghuan.dongfeng.motorcade',
                        'appActivity': 'com.aerozhonghuan.driverapp.modules.common.SplashActivity',
                        'unicodeKeyboard': True,
                        'resetKeyboard': True}
        desired_caps = {
            "platformName": "Android",
            "app": "E:\dongfeng-capp-gold1-20201013.apk",
            "deviceName": "127.0.0.1:62001"
        }
        driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)
